﻿using Microsoft.Xna.Framework;
using Rescue_of_the_Dwarvenzombies.Scene.Levels;
using Rescue_of_the_Dwarvenzombies.SceneObjects;
using Rescue_of_the_Dwarvenzombies.SceneObjects.GameObjects.Characters.Enemies;
using GameLibrary;

namespace Rescue_of_the_Dwarvenzombies.SceneLayers
{
    public class RootLayer : SceneLayer
    {
        private ISceneObject currentLevel;
        private Game _game;

        /// <summary>
        /// Initializes a new instance of the <see cref="RootLayer"/> class.
        /// </summary>
        /// <param name="game">The game.</param>
        public RootLayer(Game game)
            : base(game)
        {
            _game = game;   
            InitObjects();
            Child = new PlayerLayer(game);
            LayerName = Constant.Layer.Root;
            AI.Instance().PlayerLayer = Child;
            AI.Instance().Game = game;
            Depth = Constant.ROOT_LAYER_DEPTH;
        }

        /// <summary>
        /// Inits the objects.
        /// </summary>
        protected override sealed void InitObjects()
        {
            ILevel level = ((ILevel)_game.Services.GetService(typeof(ILevel)));  
            SceneObjects.Add(level.GetGround());
            SceneObjects.AddRange(level.GetHoles());
        }
    }
}